```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spring AI与Redis实现对话持久化 | 技术指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', 'Noto Serif SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            line-height: 1.8;
            color: #333;
            background-color: #f9f9f9;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6e48aa 0%, #9d50bb 100%);
        }
        .code-block {
            background: #282c34;
            border-radius: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        }
        .tech-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight-box {
            border-left: 4px solid #6e48aa;
            background-color: rgba(110, 72, 170, 0.05);
        }
        .drop-cap:first-letter {
            font-size: 4.5rem;
            line-height: 1;
            float: left;
            margin-right: 1rem;
            color: #6e48aa;
            font-weight: 700;
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <header class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto">
            <div class="flex flex-col md:flex-row items-center">
                <div class="md:w-1/2 mb-10 md:mb-0">
                    <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-6">
                        使用Redis持久化Spring AI对话历史
                    </h1>
                    <p class="text-xl opacity-90 mb-8">
                        让你的智能对话系统记住每一次交流，提供连贯、个性化的用户体验
                    </p>
                    <div class="flex space-x-4">
                        <a href="#implementation" class="bg-white text-purple-800 px-6 py-3 rounded-lg font-medium hover:bg-opacity-90 transition duration-300">
                            <i class="fas fa-code mr-2"></i>立即实现
                        </a>
                        <a href="#benefits" class="bg-transparent border-2 border-white text-white px-6 py-3 rounded-lg font-medium hover:bg-white hover:bg-opacity-10 transition duration-300">
                            <i class="fas fa-star mr-2"></i>技术优势
                        </a>
                    </div>
                </div>
                <div class="md:w-1/2 flex justify-center">
                    <div class="relative w-full max-w-md">
                        <div class="absolute -top-6 -left-6 w-32 h-32 bg-purple-300 rounded-full mix-blend-multiply filter blur-xl opacity-70 animate-blob"></div>
                        <div class="absolute -bottom-8 -right-6 w-32 h-32 bg-pink-300 rounded-full mix-blend-multiply filter blur-xl opacity-70 animate-blob animation-delay-2000"></div>
                        <div class="absolute top-20 right-20 w-32 h-32 bg-indigo-300 rounded-full mix-blend-multiply filter blur-xl opacity-70 animate-blob animation-delay-4000"></div>
                        <div class="relative bg-white rounded-xl shadow-2xl overflow-hidden">
                            <div class="bg-gray-800 text-white px-4 py-2 flex items-center">
                                <div class="flex space-x-2">
                                    <div class="w-3 h-3 rounded-full bg-red-500"></div>
                                    <div class="w-3 h-3 rounded-full bg-yellow-500"></div>
                                    <div class="w-3 h-3 rounded-full bg-green-500"></div>
                                </div>
                                <div class="ml-4 text-sm">对话历史存储终端</div>
                            </div>
                            <div class="p-6 font-mono text-gray-800">
                                <div class="mb-4">
                                    <span class="text-green-600">$</span> redis-cli
                                </div>
                                <div class="mb-4">
                                    <span class="text-green-600">127.0.0.1:6379></span> GET chat:history:user123
                                </div>
                                <div class="bg-gray-100 p-3 rounded">
                                    <div>1) "用户: 你好"</div>
                                    <div>2) "AI: 你好！有什么可以帮您的？"</div>
                                    <div>3) "用户: 昨天的对话记录还在吗？"</div>
                                    <div>4) "AI: 当然，Redis已经帮您保存了所有历史记录！"</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </header>

    <!-- Problem Statement -->
    <section class="py-16 px-6 bg-white">
        <div class="max-w-4xl mx-auto">
            <div class="text-center mb-12">
                <h2 class="text-3xl font-bold text-gray-900 mb-4">为什么需要对话持久化？</h2>
                <div class="w-20 h-1 bg-purple-600 mx-auto"></div>
            </div>
            
            <div class="grid md:grid-cols-3 gap-8">
                <div class="bg-gray-50 p-6 rounded-lg border border-gray-200">
                    <div class="text-purple-600 text-3xl mb-4">
                        <i class="fas fa-comment-slash"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">会话中断问题</h3>
                    <p class="text-gray-600">用户关闭浏览器或应用重启后，宝贵的对话历史全部丢失，导致每次都是新对话。</p>
                </div>
                
                <div class="bg-gray-50 p-6 rounded-lg border border-gray-200">
                    <div class="text-purple-600 text-3xl mb-4">
                        <i class="fas fa-brain"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">上下文缺失</h3>
                    <p class="text-gray-600">AI模型无法基于历史对话提供连贯回复，降低了用户体验和模型效果。</p>
                </div>
                
                <div class="bg-gray-50 p-6 rounded-lg border border-gray-200">
                    <div class="text-purple-600 text-3xl mb-4">
                        <i class="fas fa-chart-line"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">分析困难</h3>
                    <p class="text-gray-600">无法追踪和优化长期对话流程，难以改进AI模型的交互质量。</p>
                </div>
            </div>
        </div>
    </section>

    <!-- Technical Background -->
    <section class="py-16 px-6 bg-gray-50" id="background">
        <div class="max-w-6xl mx-auto">
            <div class="text-center mb-12">
                <h2 class="text-3xl font-bold text-gray-900 mb-4">技术背景</h2>
                <div class="w-20 h-1 bg-purple-600 mx-auto"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-12">
                <div>
                    <h3 class="text-2xl font-semibold mb-6 text-purple-800 flex items-center">
                        <i class="fas fa-leaf mr-3"></i> Spring AI框架核心
                    </h3>
                    <p class="mb-6 text-gray-700 drop-cap">
                        Spring AI是Spring生态系统中的新成员，旨在简化AI功能的集成。它提供了与各种大型语言模型(LLM)交互的统一接口，使开发者能够轻松实现智能对话应用。
                    </p>
                    
                    <div class="mb-8">
                        <div class="code-block p-4 mb-4">
                            <pre class="text-gray-300 text-sm"><code>// Spring AI核心组件示例
@Service
public class AIChatService {
    private final ChatClient chatClient;
    
    public AIChatService(ChatClient chatClient) {
        this.chatClient = chatClient;
    }
    
    public String generateResponse(String prompt) {
        ChatResponse response = chatClient.call(new Prompt(prompt));
        return response.getResult().getOutput().getContent();
    }
}</code></pre>
                        </div>
                    </div>
                    
                    <div class="highlight-box p-6 rounded-lg mb-8">
                        <h4 class="font-bold text-lg mb-3 text-purple-800">Spring AI的主要优势：</h4>
                        <ul class="list-disc pl-5 space-y-2 text-gray-700">
                            <li>统一的AI提供商抽象层</li>
                            <li>简化AI功能集成</li>
                            <li>灵活的提示工程支持</li>
                            <li>与Spring生态无缝整合</li>
                        </ul>
                    </div>
                </div>
                
                <div>
                    <h3 class="text-2xl font-semibold mb-6 text-purple-800 flex items-center">
                        <i class="fas fa-database mr-3"></i> Redis技术优势
                    </h3>
                    <p class="mb-6 text-gray-700">
                        Redis是一个开源的内存数据库，以其高性能、灵活的数据结构和持久化能力而闻名。对于AI对话应用来说，Redis提供了理想的会话存储解决方案。
                    </p>
                    
                    <div class="mb-8">
                        <div class="mermaid">
                            pie
                                title Redis在AI对话中的优势
                                "高性能读写" : 35
                                "丰富数据结构" : 25
                                "TTL自动过期" : 20
                                "持久化选项" : 15
                                "集群扩展" : 5
                        </div>
                    </div>
                    
                    <div class="grid grid-cols-2 gap-4">
                        <div class="bg-white p-4 rounded-lg border border-gray-200">
                            <div class="text-purple-600 mb-2">
                                <i class="fas fa-bolt"></i>
                            </div>
                            <h4 class="font-semibold">毫秒级响应</h4>
                            <p class="text-sm text-gray-600">内存操作确保快速读写</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg border border-gray-200">
                            <div class="text-purple-600 mb-2">
                                <i class="fas fa-layer-group"></i>
                            </div>
                            <h4 class="font-semibold">多种数据结构</h4>
                            <p class="text-sm text-gray-600">String, Hash, List等</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg border border-gray-200">
                            <div class="text-purple-600 mb-2">
                                <i class="fas fa-clock"></i>
                            </div>
                            <h4 class="font-semibold">自动过期</h4>
                            <p class="text-sm text-gray-600">TTL管理会话生命周期</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg border border-gray-200">
                            <div class="text-purple-600 mb-2">
                                <i class="fas fa-shield-alt"></i>
                            </div>
                            <h4 class="font-semibold">数据安全</h4>
                            <p class="text-sm text-gray-600">RDB/AOF持久化</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Implementation Section -->
    <section class="py-16 px-6 bg-white" id="implementation">
        <div class="max-w-6xl mx-auto">
            <div class="text-center mb-12">
                <h2 class="text-3xl font-bold text-gray-900 mb-4">实现步骤</h2>
                <div class="w-20 h-1 bg-purple-600 mx-auto"></div>
            </div>
            
            <div class="mb-16">
                <h3 class="text-2xl font-semibold mb-6 text-purple-800">1. 环境准备</h3>
                
                <div class="grid md:grid-cols-2 gap-8 mb-8">
                    <div>
                        <h4 class="text-lg font-medium mb-4 flex items-center">
                            <span class="bg-purple-600 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3 text-sm">1</span>
                            技术栈准备
                        </h4>
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <ul class="list-disc pl-5 space-y-2 text-gray-700">
                                <li>JDK 17+</li>
                                <li>Spring Boot 3.2+</li>
                                <li>Spring AI 0.8.0+</li>
                                <li>Spring Data Redis</li>
                                <li>Redis 6.0+</li>
                            </ul>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="text-lg font-medium mb-4 flex items-center">
                            <span class="bg-purple-600 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3 text-sm">2</span>
                            Maven配置
                        </h4>
                        <div class="code-block p-4">
                            <pre class="text-gray-300 text-sm"><code>&lt;dependencies&gt;
    &lt;!-- Spring Boot --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
    &lt;/dependency&gt;
    
    &lt;!-- Spring AI --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.ai&lt;/groupId&gt;
        &lt;artifactId&gt;spring-ai-openai-spring-boot-starter&lt;/artifactId&gt;
        &lt;version&gt;0.8.0&lt;/version&gt;
    &lt;/dependency&gt;
    
    &lt;!-- Redis支持 --&gt;
    &lt;dependency&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-data-redis&lt;/artifactId&gt;
    &lt;/dependency&gt;
&lt;/dependencies&gt;</code></pre>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="mb-16">
                <h3 class="text-2xl font-semibold mb-6 text-purple-800">2. Redis数据模型设计</h3>
                
                <div class="grid md:grid-cols-2 gap-8 mb-8">
                    <div>
                        <h4 class="text-lg font-medium mb-4 flex items-center">
                            <span class="bg-purple-600 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3 text-sm">3</span>
                            数据结构设计
                        </h4>
                        <div class="code-block p-4 mb-4">
                            <pre class="text-gray-300 text-sm"><code>@Data
@AllArgsConstructor
@NoArgsConstructor
public class ChatMessage implements Serializable {
    private String role;      // 角色：user, assistant
    private String content;   // 消息内容
    private long timestamp;   // 时间戳
    
    // 转换为Spring AI的Message对象
    public Message toAIMessage() {
        if ("user".equals(role)) {
            return new UserMessage(content);
        } else {
            return new AiMessage(content);
        }
    }
}</code></pre>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="text-lg font-medium mb-4 flex items-center">
                            <span class="bg-purple-600 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3 text-sm">4</span>
                            Redis键设计
                        </h4>
                        <div class="bg-white p-4 rounded-lg border border-gray-200">
                            <div class="mermaid">
                                flowchart LR
                                    A[chat:history:{chatId}] --> B[消息ID1]
                                    A --> C[消息ID2]
                                    A --> D[消息ID3]
                                    B --> E[角色: user]
                                    B --> F[内容: "你好"]
                                    B --> G[时间戳: 123456789]
                            </div>
                        </div>
                    </div>
                </div>
                
                <div class="highlight-box p-6 rounded-lg">
                    <h4 class="font-bold text-lg mb-3 text-purple-800">TTL策略建议：</h4>
                    <div class="grid md:grid-cols-3 gap-4">
                        <div class="bg-white p-4 rounded-lg">
                            <div class="text-purple-600 font-bold mb-2">短期会话</div>
                            <p class="text-sm text-gray-600">30分钟 ~ 2小时</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg">
                            <div class="text-purple-600 font-bold mb-2">中期会话</div>
                            <p class="text-sm text-gray-600">1天 ~ 7天</p>
                        </div>
                        <div class="bg-white p-4 rounded-lg">
                            <div class="text-purple-600 font-bold mb-2">长期会话</div>
                            <p class="text-sm text-gray-600">30天 ~ 90天</p>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="mb-16">
                <h3 class="text-2xl font-semibold mb-6 text-purple-800">3. 核心代码实现</h3>
                
                <div class="grid md:grid-cols-2 gap-8 mb-8">
                    <div>
                        <h4 class="text-lg font-medium mb-4 flex items-center">
                            <span class="bg-purple-600 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3 text-sm">5</span>
                            Redis存储库实现
                        </h4>
                        <div class="code-block p-4">
                            <pre class="text-gray-300 text-sm"><code>@Repository
public class RedisChatHistoryRepository implements ChatHistoryRepository {
    private final RedisTemplate&lt;String, Object&gt; redisTemplate;
    
    @Override
    public void append(String chatId, Message message) {
        String key = generateChatKey(chatId);
        ChatMessage chatMessage = ChatMessage.fromAIMessage(message);
        String messageId = UUID.randomUUID().toString();
        
        redisTemplate.opsForHash().put(key, messageId, chatMessage);
        setChatExpiration(chatId, DEFAULT_EXPIRATION);
    }
    
    @Override
    public List&lt;Message&gt; getMessages(String chatId) {
        String key = generateChatKey(chatId);
        List&lt;Object&gt; values = redisTemplate.opsForHash().values(key);
        
        return values.stream()
            .map(obj -&gt; ((ChatMessage)obj).toAIMessage())
            .collect(Collectors.toList());
    }
}</code></pre>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="text-lg font-medium mb-4 flex items-center">
                            <span class="bg-purple-600 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3 text-sm">6</span>
                            Spring AI集成
                        </h4>
                        <div class="code-block p-4 mb-4">
                            <pre class="text-gray-300 text-sm"><code>@Configuration
public class AIConfig {
    @Bean
    public ChatClient chatClient(ChatModel chatModel, 
                               RedisChatHistoryRepository historyRepository) {
        return new DefaultChatClient(chatModel, historyRepository);
    }
    
    @Bean
    public ChatHistory chatHistory(RedisChatHistoryRepository historyRepository) {
        return new DefaultChatHistory(historyRepository, "default");
    }
}</code></pre>
                        </div>
                        
                        <div class="bg-white p-4 rounded-lg border border-gray-200 mt-4">
                            <h4 class="font-semibold mb-2">配置Redis连接</h4>
                            <div class="code-block p-4">
                                <pre class="text-gray-300 text-sm"><code># application.properties
spring.data.redis.host=localhost
spring.data.redis.port=6379
spring.data.redis.password=yourpassword</code></pre>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            
            <div>
                <h3 class="text-2xl font-semibold mb-6 text-purple-800">4. 生产环境部署</h3>
                
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h4 class="text-lg font-medium mb-4 flex items-center">
                            <span class="bg-purple-600 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3 text-sm">7</span>
                            安全配置
                        </h4>
                        <div class="bg-gray-50 p-4 rounded-lg">
                            <ul class="list-disc pl-5 space-y-2 text-gray-700">
                                <li>启用TLS/SSL加密</li>
                                <li>配置访问密码</li>
                                <li>禁用危险命令(FLUSHALL等)</li>
                                <li>网络ACL控制</li>
                                <li>敏感信息加密存储</li>
                            </ul>
                        </div>
                    </div>
                    
                    <div>
                        <h4 class="text-lg font-medium mb-4 flex items-center">
                            <span class="bg-purple-600 text-white rounded-full w-6 h-6 flex items-center justify-center mr-3 text-sm">8</span>
                            多环境管理
                        </h4>
                        <div class="code-block p-4">
                            <pre class="text-gray-300 text-sm"><code># application-dev.properties
spring.data.redis.host=localhost
spring.data.redis.password=devpassword

# application-prod.properties
spring.data.redis.host=${REDIS_HOST}
spring.data.redis.password=${REDIS_PASSWORD}
spring.data.redis.ssl=true</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Benefits Section -->
    <section class="py-16 px-6 bg-purple-50" id="benefits">
        <div class="max-w-4xl mx-auto">
            <div class="text-center mb-12">
                <h2 class="text-3xl font-bold text-gray-900 mb-4">技术优势</h2>
                <div class="w-20 h-1 bg-purple-600 mx-auto"></div>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <div class="text-purple-600 text-4xl mb-4">
                        <i class="fas fa-tachometer-alt"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">性能卓越</h3>
                    <p class="text-gray-600">Redis的内存操作确保毫秒级响应，即使在频繁读写场景下也能保持高性能。</p>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <div class="text-purple-600 text-4xl mb-4">
                        <i class="fas fa-project-diagram"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">上下文连贯</h3>
                    <p class="text-gray-600">持久化的对话历史使AI能够基于完整上下文提供更连贯、更智能的回复。</p>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <div class="text-purple-600 text-4xl mb-4">
                        <i class="fas fa-user-friends"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">个性化体验</h3>
                    <p class="text-gray-600">系统能够记住用户偏好和历史交互，提供真正个性化的对话体验。</p>
                </div>
                
                <div class="bg-white p-6 rounded-lg shadow-md">
                    <div class="text-purple-600 text-4xl mb-4">
                        <i class="fas fa-chart-bar"></i>
                    </div>
                    <h3 class="text-xl font-semibold mb-3">分析优化</h3>
                    <p class="text-gray-600">持久化的对话可用于分析和改进AI模型，提升整体交互质量。</p>
                </div>
            </div>
            
            <div class="text-center">
                <a href="#implementation" class="inline-block bg-purple-600 text-white px-8 py-3 rounded-lg font-medium hover:bg-purple-700 transition duration-300">
                    <i class="fas fa-rocket mr-2"></i>立即开始实现
                </a>
            </div>
        </div>
    </section>

    <!-- Practical Cases -->
    <section class="py-16 px-6 bg-white">
        <div class="max-w-6xl mx-auto">
            <div class="text-center mb-12">
                <h2 class="text-3xl font-bold text-gray-900 mb-4">实战案例</h2>
                <div class="w-20 h-1 bg-purple-600 mx-auto"></div>
            </div>
            
            <div class="grid md:grid-cols-3 gap-8">
                <div class="tech-card bg-white border border-gray-200 rounded-lg overflow-hidden transition duration-300">
                    <div class="p-6">
                        <div class="text-purple-600 text-3xl mb-4">
                            <i class="fas fa-robot"></i>
                        </div>
                        <h3 class="text-xl font-semibold mb-3">聊天机器人</h3>
                        <p class="text-gray-600 mb-4">实现多轮对话记忆，让机器人记住用户的偏好和历史对话。</p>
                        <div class="code-block p-3">
                            <pre class="text-gray-300 text-xs"><code>@PostMapping("/chat/{chatId}")
public String chat(@PathVariable String chatId, 
                  @RequestParam String message) {
    return chatService.generateResponse(chatId, message);
}</code></pre>
                        </div>
                    </div>
                </div>
                
                <div class="tech-card bg-white border border-gray-200 rounded-lg overflow-hidden transition duration-300">
                    <div class="p-6">
                        <div class="text-purple-600 text-3xl mb-4">
                            <i class="fas fa-users"></i>
                        </div>
                        <h3 class="text-xl font-semibold mb-3">多租户系统</h3>
                        <p class="text-gray-600 mb-4">为不同用户隔离会话数据，确保隐私和安全。</p>
                        <div class="code-block p-3">
                            <pre class="text-gray-300 text-xs"><code>String userChatId = userId + ":" + sessionId;
chatService.saveMessage(userChatId, message);</code></pre>
                        </div>
                    </div>
                </div>
                
                <div class="tech-card bg-white border border-gray-200 rounded-lg overflow-hidden transition duration-300">
                    <div class="p-6">
                        <div class="text-purple-600 text-3xl mb-4">
                            <i class="fas fa-flask"></i>
                        </div>
                        <h3 class="text-xl font-semibold mb-3">A/B测试</h3>
                        <p class="text-gray-600 mb-4">跟踪不同版本的对话效果，优化AI模型。</p>
                        <div class="code-block p-3">
                            <pre class="text-gray-300 text-xs"><code>// 记录测试指标
redisTemplate.opsForHash().increment(
    "abtest:metrics", 
    testGroup + ":messageCount", 
    1
);</code></pre>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            fontFamily: 'Noto Sans SC, sans-serif'
        });
        
        // 简单的滚动动画
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```